// import { createRouter, createWebHashHistory } from 'vue-router'
// import Home from '../views/Home.vue'

// const routes = [
//   {
//     path: '/',
//     name: 'Home',
//     component: Home
//   },
//   {
//     path: '/about',
//     name: 'About',
//     // route level code-splitting
//     // this generates a separate chunk (about.[hash].js) for this route
//     // which is lazy-loaded when the route is visited.
//     component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
//   }
// ]
// 创建路由实例
// const router = createRouter({
//   // 使用hash方式实现路由
//   history: createWebHashHistory(),
//   // 配置路由规则，写法和之前一样
//   routes
// })

// export default router
import { createRouter, createWebHashHistory } from 'vue-router'
import PlayGround from '@/views/Playground'
import Category from '@/views/Category'
import CategorySub from '@/views/Category/Sub'
const Layout = () => import('@/views/Layout/Layout.vue')
const Home = () => import('@/views/Home/index')
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      { path: '/', component: Home },
      {
        path: '/category/:id',
        component: Category
      },
      {
        path: '/category/sub/:id',
        component: CategorySub
      }
    ]
  },
  {
    path: '/play',
    component: PlayGround
  }
]
const router = createRouter({
  history: createWebHashHistory(),
  routes
})
export default router
